

import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.util.List;

/**
 *
 * @author Éric Beaudry
 */
public class Main {

    public static void main(String args[])
            throws IOException
    {

        Parseur parseur = new Parseur();
        Reader reader = null;
        if(args.length>0)
            reader = new FileReader(args[0]);
        else
            reader = new InputStreamReader(System.in);
        StreamTokenizer stokenizer = new StreamTokenizer(reader);


        parseur.parse(stokenizer);

        Heuristique h = new Heuristique(parseur.monde);
        List<String> plan = AStar.generatePlan(parseur.etatInitial, parseur.but, h);

        PrintStream out;
        if(args.length>1)
            out = new PrintStream(args[1]);
        else
            out = System.out;

        out.println("Plan {");
        int nbaction = 0;
        for(String action : plan)
            out.println("a" + nbaction++ + ": " + action + ";");
        for(int i=1;i<nbaction;i++)
            out.println("a" + (i-1) + " < a" + i + ";");
        out.println("}");

    }

}
